﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{

    <script type="text/javascript">
        var renderTable;
        var setSelectData;
        var userType = 0;

        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'treetable', 'index', 'laydate', 'form', 'dropdown'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate
                , dropdown = layui.dropdown;

            laydate.render({
                elem: '#rebateTime'
                , range: true
            });

            laydate.render({
                elem: '#balanceDate'
            });

            $.getJSON("/Referral/GetCommissionDetailedReportSymbol", function (result) {
                let plat = result.data;
                $('#symbol').append(new Option(top.lang.pleaseSelect, ""));
                plat.forEach(function (v) {
                    $('#symbol').append(new Option(v, v));
                });
                layui.form.render("select");
            });

            // 渲染表格
            renderTable = function () {
                table.render({
                    elem: '#table-datalist'
                    , url: '/Referral/GetCommissionDetailedReport'
                    //, toolbar: '#table-datalist-toolbar'
                    , limit: 20
                    , title: '日返佣详情'
                    , cols: [[
                        {
                            field: 'MT5Account', title: 'MT5账号', templet: function (res) {
                                return res.tradingAccount;
                            }
                        }
                        , {
                            field: 'CRMAccount', title: 'CRM账户', templet: function (res) {
                                return res.name + "/" + res.crmAccount;
                            }
                        }
                        , { field: 'symbol', title: '品种' }
                        , { field: 'volume', title: '交易量' }
                        , { field: 'programme', title: '返佣方案' }
                        , { field: 'rebateLevel', title: '返佣等级' }
                        , { field: 'rebateAmount', title: '返佣金额' }
                        , { field: 'balanceDate', title: '结算日期' }
                        , { field: 'rebateTime', title: '返佣时间' }
                    ]]
                    , id: "tableReload"
                    , defaultToolbar: false
                    , page: { layout: ['prev', 'page', 'next', 'refresh'] }
                    , done: function (res) {
                        if (res.count == 0) {
                            $(".layui-table-main").html('<div class="layui-none">' + top.lang.noData + '</div>');
                        }
                        layer.closeAll('loading');
                        /**多语言初始化 */
                        top.SetListPageLanguage(layui);
                        top.SetSelectLanguage(layui);
                    }
                });
            };
            renderTable();
            renderTable();

            //头工具栏事件
            table.on('toolbar(table-datalist)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                var data = checkStatus.data;
                switch (obj.event) {
                    case "export":
                        $.getJSON("/Referral/GetCommissionDetailedReport?page=0&limit=0", function (result) {
                            if (result.code == 0) {
                                table.exportFile('tableReload', result.data, 'xls');
                            }
                        });
                        break;
                };
            });

            form.on('submit(search)', function (data) {
                //执行重载
                table.reload('tableReload', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        alllName: $("#alllName").val(),
                        symbol: $("#symbol option:selected").val(),
                        rebateTime: $("#rebateTime").val(),
                        balanceDate: $("#balanceDate").val()
                    }
                });
            });

            form.on('submit(resetting)', function (data) {
                $("#alllName").val(),
                    $("#symbol").val()
                $("#rebateTime").val(),
                    $("#balanceDate").val()
                layui.form.render("select");
                //执行重载
                table.reload('tableReload', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        alllName: "",
                        symbol: "",
                        rebateTime: "",
                        balanceDate: "",

                    }
                });
            });
        });

    </script>
}
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" lay-filter="component-form-element">
                    <div class="layui-card-body layui-form layui-form-pane" style="padding: 15px;">
                        <div id="divSearch" class="layui-col-space10 layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="alllName">姓名/CRM账户/MT5账号</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="alllName" name="alllName" placeholder="alllName" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="symbol">交易品种</label>
                                <div class="layui-input-inline">
                                    <select name="symbol" id="symbol">
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="balanceDate">结算日期</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="balanceDate" name="balanceDate" placeholder="balanceDate" lay-key="8">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label" lay-event="rebateTime">返佣时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="rebateTime" name="rebateTime" placeholder="rebateTime" lay-key="8">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item" style="text-align:center;">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-event="search" lay-submit lay-filter="search">搜索</button>
                                <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="resetting" lay-event="resetting">重置</button>
                                @*<button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="refresh" lay-event="refresh">刷新</button>*@
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div class="layui-tab-content">
                            <table class="layui-hide" id="table-datalist" lay-filter="table-datalist"></table>
                            @*   <script type="text/html" id="zizeng">
                        {{d.LAY_TABLE_INDEX+1}}
                        </script>*@
                            <script type="text/html" id="table-datalist-toolbar">
                                <div class="layui-btn-container" id="layui-btn-container">
                                    <button class="layui-btn layui-btn-sm layui-btn-primary" lay-event="export">导出</button>
                                </div>
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>